package com.ourteam.product.requirement.api;

import org.apache.commons.lang3.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.requirement.dao.ProductDefineDAOQueryBean;
import com.ourteam.product.requirement.domain.ProductDefineBean;

public class ProductDefineSearchModel extends AbstractSearchModel<ProductDefineDAOQueryBean> {

	private String code;

	private String name;

	private String status;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductDefineBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductDefineDAOQueryBean queryBean) throws Exception {

		ProductDefineDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (StringUtils.isNoneBlank(this.code)) {
			criteria.andProductCodeLike(this.code);
		}

		if (StringUtils.isNoneBlank(this.name)) {
			criteria.andProductNameLike(this.name);
		}

		if (StringUtils.isNoneBlank(this.status)) {
			criteria.andProductCodeEqualTo(this.status);
		}

	}

}
